home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / dclistview / dclisttest.e < prev    next >
Text File  |  1998-01-17  |  2KB  |  58 lines

  1. OPT PREPROCESS, OSVERSION=37
  2.  
  3. MODULE 'tools/exceptions', 'tools/EasyGUI', 'exec/nodes', 'exec/lists',
  4.        'plugins/dclistview', 'tools/constructors', 'utility', 'utility/tagitem'
  5.  
  6. DEF result=-1
  7.  
  8. PROC main() HANDLE
  9.   DEF dclist:PTR TO dclistview
  10.   DEF list, a, nodes
  11.   IF (utilitybase:=OpenLibrary('utility.library', 37)) =NIL THEN Raise("util")
  12.   list:=newlist()
  13.   nodes:=['zero','one','two','three','four','five','six','seven',
  14.           'eight','nine','ten','eleven','twelve','thirteen','fourteen']
  15.   ForAll({a}, nodes, `AddTail(list, newnode(NIL, a)))
  16.   NEW dclist.dclistview([DCLV_LABEL, 'L_abel',
  17.                          DCLV_RELX, 15,
  18.                          DCLV_RELY, 7,
  19.                          DCLV_LIST, list,
  20.                          DCLV_CURRENT, result,
  21.                          TAG_DONE])
  22.   easyguiA('Double Click test',
  23.           [EQROWS,
  24.             [DCLIST, {listaction},dclist,TRUE],  ->note use of ID constant (=PLUGIN)
  25.             [EQCOLS,
  26.               [SBUTTON, {okaction}, '_OK', dclist, "o"],
  27.               [SBUTTON, {disable}, '_Disable', dclist, "d"],
  28.               [SBUTTON, {cancelaction}, '_Cancel', NIL, "c"]
  29.             ]
  30.           ])
  31. EXCEPT DO
  32.   IF utilitybase THEN CloseLibrary(utilitybase)
  33.   END dclist
  34.   IF exception<>"QUIT" THEN report_exception()
  35. ENDPROC
  36.  
  37. PROC listaction(info, dclist:PTR TO dclistview)
  38.   IF dclist.get(DCLV_CLICK) THEN okaction(dclist, NIL)
  39.   PrintF('Current Selection: \d\n',dclist.get(DCLV_CURRENT))
  40. ENDPROC
  41.  
  42. PROC okaction(dclist:PTR TO dclistview, info)
  43.   IF (result:=dclist.get(DCLV_CURRENT))= -1
  44.     PrintF('No selection made\n')
  45.     cancelaction(info)
  46.   ENDIF
  47.   PrintF('Final Selection: \d\n',result)
  48.   quitgui(result)
  49. ENDPROC
  50.  
  51. PROC disable(dclist:PTR TO dclistview, info) IS dclist.set(DCLV_DISABLED, dclist.get(DCLV_DISABLED)=FALSE)
  52.  
  53. PROC cancelaction(info)
  54.   PrintF('Operation cancelled.\n')
  55.   quitgui()
  56. ENDPROC
  57.  
  58.